package webgamemaker.FightCanvas;

public class FighterActionMove implements FighterAction 
{
	public int x, y, speedX, speedY;
	public FighterActionMove(int x, int y, int speedX, int speedY)
	{
		this.x = x;
		this.y = y;
		this.speedX = speedX;
		this.speedY = speedY;
	}
	
	public void apply(Fighter fighter) 
	{
		if(fighter.x < x)
			fighter.x += Math.min(speedX, x-fighter.x);
		else if(fighter.x > x)
			fighter.x -= Math.min(speedX, fighter.x-x);
		if(fighter.y < y)
			fighter.y += Math.min(speedY, y-fighter.y);
		else if(fighter.y > y)
			fighter.y -= Math.min(speedY, fighter.y-y);	
	}
	
	public boolean isFinished(Fighter fighter)
	{
		return fighter.x == x && fighter.y == y;
	}

}
